package com.base.pig.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.base.pig.entity.WaterQualityDevice;
import com.base.pig.service.WaterQualityDeviceService;
import com.base.pig.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjh
 * @since 2023-07-07
 */
@RestController
@Api(value = "WaterQualityDeviceController", tags = "水质柜数据查询")
@RequestMapping("/water-quality-device")
public class WaterQualityDeviceController {

    @Autowired
    public WaterQualityDeviceService waterQualityDeviceService;

    @ApiOperation(value = "查询")
    @PostMapping("/list")
    public R list(){
        List<WaterQualityDevice> waterQualityDeviceList = waterQualityDeviceService.list();
        return R.ok(waterQualityDeviceList,"查询成功");
    }

    @ApiOperation(value = "分页查询")
    @PostMapping("/pageList/{pageNum}/{pageSize}")
    public R pageList(@PathVariable("pageNum")Long pageNum,
                  @PathVariable("pageSize")Long pageSize,
                  @RequestBody WaterQualityDevice waterQualityDevice){
        IPage<WaterQualityDevice> page = waterQualityDeviceService.page(
        new Page<>(pageNum, pageSize),
        new QueryWrapper<>(waterQualityDevice));
        return R.ok(page,"分页查询成功");
    }









}
